implementation\r
\r
uses\r
+ Forms,\r
StdCtrls,\r
common;\r
\r
BytesRead, BytesDone: DWORD;\r
buffer: packed array[0..512] of Char;\r
Error: DWORD;\r
+ Wait_Result: DWORD;\r
s: string;\r
\r
begin\r
raise eGPSBabelError.CreateFmt(\r
_('Could not run "gpsbabel.exe" (Error %d)!'), [Error]);\r
end;\r
- while (WaitforSingleObject (ProcessInfo.hProcess, 0)) <> WAIT_OBJECT_0 do sleep(100);\r
- if not GetExitCodeProcess(ProcessInfo.hProcess, Error) then Error := 0;\r
-\r
- if (Error <> 0) and (Error <> 1) then\r
- raise eGPSBabelError.CreateFmt(_('"gpsbabel.exe" returned error 0x%x (%d)'), [Error, Error]);\r
\r
s := '';\r
\r
- PeekNamedPipe(hRead, nil, 0, nil, @BytesRead, nil);\r
+ repeat\r
+ Wait_Result := WaitforSingleObject(ProcessInfo.hProcess, 50);\r
+ if PeekNamedPipe(hRead, nil, 0, nil, @BytesRead, nil) then\r
+ begin\r
+ Application.ProcessMessages;\r
+ while (BytesRead > 0) do\r
+ begin\r
+ ReadFile(hRead, Buffer, SizeOf(buffer)-1, BytesDone, nil);\r
+ buffer[BytesDone] := #0;\r
+ s := s + string(buffer);\r
+ Dec(BytesRead, BytesDone);\r
+ end;\r
+ end;\r
+ until (Wait_Result = WAIT_OBJECT_0);\r
\r
- while (BytesRead > 0) do\r
- begin\r
- ReadFile(hRead, Buffer, SizeOf(buffer)-1, BytesDone, nil);\r
- buffer[BytesDone] := #0;\r
- s := s + string(buffer);\r
+ if not GetExitCodeProcess(ProcessInfo.hProcess, Error) then Error := 0;\r
\r
- Dec(BytesRead, BytesDone);\r
- end;\r
+ if (Error <> 0) and (Error <> 1) then\r
+ raise eGPSBabelError.CreateFmt(_('"gpsbabel.exe" returned error 0x%x (%d)'), [Error, Error]);\r
\r
Output.Clear;\r
Output.SetText(PChar(s));\r